<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('审读样本列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>样本名称：</label>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <div class="">
                                <label class="">审读介质：</label>
                                <select name="medium" class="form-control noselect2 selectpicker" th:with="type=${@dict.getType('review_sample_medium')}">
                                    <option value="">--请选择审读介质--</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </div>
                        </li>
                        <li>
                            <label>出版单位：</label>
                            <input type="text" name="publisher"/>
                        </li>
                        <li>
                            <label>出版期刊：</label>
                            <input type="text" name="journalSuper"/>
                        </li>

                        <li class="select-time">
                            <label>缴送时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginDeliveryTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endDeliveryTime]"/>
                        </li>
<!--                        <li>-->
<!--                            <label>出版标识：</label>-->
<!--                            <input type="text" name="identification"/>-->
<!--                        </li>-->

<!--                        <li>-->
<!--                            <label>审读结果：</label>-->
<!--&lt;!&ndash;                            <input type="text" name="ex1"/>&ndash;&gt;-->
<!--&lt;!&ndash;                             name="params[beginDeliveryTime]"&ndash;&gt;-->
<!--                            <select name="params[result]"  class="form-control noselect2 selectpicker" >-->
<!--                                <option value="">&#45;&#45;请选择&#45;&#45;</option>-->
<!--                                <option th:text="已审读"  th:value="已审读"></option>-->
<!--                                <option th:text="未审读"  th:value="未审读" selected></option>-->
<!--                            </select>-->
<!--                        </li>-->

                        <li>
                            <label>创建人：</label>
                            <input type="text" name="createName"/>
                        </li>

                        <!--                            <li>-->
                        <!--                                <label>封面：</label>-->
                        <!--                                <input type="text" name="cover"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>说明：</label>-->
                        <!--                                <input type="text" name="sampleDesc"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>稿件id：</label>-->
                        <!--                                <input type="text" name="reviewId"/>-->
                        <!--                            </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('publish:sample:edit')}]];
    var removeFlag = [[${@permission.hasPermi('publish:sample:remove')}]];
    var prefix = ctx + "publish/sample";

    // 获取数据字典数据
    var datas = [[${@dict.getType('review_sample_medium')}]];

    $(function () {
        var options = {
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            striped: true,    //是否显示行间隔色
            clickToSelect: true, //是否启用点击选中行
            modalName: "审读样本关联",
            queryParams:queryParams,
            columns: [{
                radio: true
            },
                {
                    field: 'id',
                    title: 'id',
                    // visible: false
                },
                // {
                //     field: 'index',
                //     align: 'center',
                //     title: "序号",
                //     formatter: function (value, row, index) {
                //         var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                //         return columnIndex + $.table.serialNumber(index);
                //     }
                // },
                // {
                //     field: 'createName',
                //     title: '创建人姓名'
                // },
                // {
                //     field: 'createBy',
                //     title: '创建人工号'
                // },
                {
                    //field: 'reviewId',
                    title: '审读结果',
                    formatter: function (value, row, index) {
                        // debugger
                        var _v = row.reviewId;
                        if(_v == 0||$.common.isEmpty(_v)){
                            return '未审读';
                        }else{
                            return '已审读';
                        }
                    }
                },
                {
                    field: 'name',
                    title: '样本名称'
                },
                {
                    field: 'publisher',
                    title: '出版单位',
                    sortable: true
                },
                {
                    // field: 'journalSuper',
                    title: '出版期刊',
                    formatter: function (value, row, index) {
                        return row.journalSuper + ':'+row.journalSub;
                    }
                },

                {
                    field: 'medium',
                    title: '审读介质',
                    // 格式化数据字典
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                // {
                //     field: 'journalSuper',
                //     title: '期刊主分类'
                // },
                // {
                //     field: 'journalSub',
                //     title: '期刊子分类'
                // },
                {
                    field: 'deliveryTime',
                    title: '缴送时间',
                    sortable: true
                },
                {
                    field: 'createName',
                    title: '创建人',
                    sortable: true
                },
                {
                    field: 'identification',
                    title: '出版标识'
                },
                // {
                //     field: 'reviewId',
                //     title: '稿件id'
                // },
                ]
        };
        $.table.init(options);
    });

    function queryParams(params) {
        //debugger
        var search = $.table.queryParams(params);
        // params[result]  name
        //search.name = '样本';
        search['params'] = {'result':'未审读'};
        // search.params={};
        // search.params['result']='未审读';
        //search.params.result = '未审读';
        return search;
    }

    /* 添加-选择-提交 */
    function submitHandler() {
        // var rows = $.table.selectFirstColumns();
        // var rows = $.table.selectColumns('id');
        // var names = $.table.selectColumns('expertName');
        var rows  = $("#bootstrap-table").bootstrapTable('getSelections');
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }


        //alert(rows.join());
        console.log(rows);
        $.modal.close();
        // 父页面的方法
        // parent.selectUsers();
        // 父页面的变量
        parent.setSample(rows);
        //parent.$('#userids').html(rows.join());
    }
</script>
</body>
</html>